package top.suven.base.http.admin.sec.dao;

import org.apache.ibatis.annotations.*;
import top.suven.base.core.mybatis.crud.CommonCrudMapper;
import top.suven.base.http.admin.sec.model.AdminRole;

import java.util.List;
/**   
 * @Title: AdminRoleService.java
 * @Description: 操作员角色关系的数据交互类
 * @author lixiangling
 * @date   2018/08/13 17:07:07
 * @version V1.0.0
 * ----------------------------------------------------------------------------
 *  modifyer    modifyTime                 comment
 *
 * ----------------------------------------------------------------------------
 *
 */
public interface AdminRoleDao extends CommonCrudMapper<AdminRole> {
    @Select("<script> " +
    "select * from  sec_admin_role where status='1' and enable_status='1' and admin_role_id in " +
    "<foreach item='item' index='index' collection='idList' open='(' separator=',' close=')'> " +
    "#{item} " +
    "</foreach> " +
    "</script>")
    @Results(
        id="adminRole",
        value = {
            @Result(column = "admin_role_id" , property = "adminRoleId"),
			@Result(column = "role_code" , property = "roleCode"),
			@Result(column = "admin_code" , property = "adminCode"),
			@Result(column = "status" , property = "status"),
			@Result(column = "reorder" , property = "reorder"),
			@Result(column = "remark" , property = "remark"),
			@Result(column = "enable_status" , property = "enableStatus")
        }
    )
    List<AdminRole> getSysRoleMenuByRoleCodeList(@Param("idList") List<Long> idList);
    /**
     * @Title: 删除操作员角色关系信息
     * @Description:id @{Link Long[]}
     * @param
     * @return
     * @throw
     * @author lixiangling
     * @date 2018/08/13 17:07:07
     *  --------------------------------------------------------
     *  modifyer    modifyTime                 comment
     *
     *  --------------------------------------------------------
     */
    @Update("<script> " +
            "UPDATE sec_admin_role set status='0'"+
            "WHERE admin_role_id IN " +
            "<foreach item='item' index='index' collection='idList' open='(' separator=',' close=')'> " +
            "#{item} " +
            "</foreach> " +
            "</script>")
    void del(@Param("idList") List<Long> idList);
    /**
     * @Title: 禁用操作员角色关系信息
     * @Description:id @{Link Long}
     * @param
     * @return
     * @throw
     * @author lixiangling
     * @date 2018/08/13 17:07:07
     *  --------------------------------------------------------
     *  modifyer    modifyTime                 comment
     *
     *  --------------------------------------------------------
     */
     @Update("<script> " +
             "UPDATE sec_admin_role  " +
             "SET admin_role_id = #{enableStatus}  " +
             "WHERE user_id IN " +
             "<foreach item='item' index='index' collection='idList' open='(' separator=',' close=')'> " +
             "#{item} " +
             "</foreach> " +
             "</script>")
     void updateEnableStatus(@Param("enableStatus") String enableStatus, @Param("idList") List<Long> idList);
}